home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Programming / MPW Dynamo 3.0 / dynamo.sample / sample.a < prev   
Encoding:
Text File  |  1990-03-17  |  8.0 KB  |  420 lines  |  [TEXT/MPS ]

  1. *******************************************************
  2. *                        *
  3. * Apple II 8-bit runtime sample exerciser.        *
  4. * Copyright (C) 1990 Apple Computer.        *
  5. * Version 3.0                    *
  6. *                        *
  7. * Written by Eric Soldan, Apple II DTS        *
  8. *                        *
  9. *******************************************************
  10.  
  11.         include    ':dynamo.includes:sys.equ'
  12.         include    ':dynamo.includes:rt.h'
  13.         include    ':dynamo.includes:rt.macros'
  14.  
  15.         include    'app.config'
  16.  
  17. *********************************************
  18.  
  19.         export    varspace
  20. varspace        PROC
  21.         ds.b    256
  22.         endp
  23.  
  24. ******************
  25.  
  26.         export    strspace
  27. strspace        PROC
  28.         export    strlens, maxstrlens, strlocs
  29. strlens        ds.b    numstrings
  30. maxstrlens    dc.b    maxstr1, maxstr2
  31. strlocs        dc.w    str1loc, str2loc
  32.         endp
  33.  
  34. ******************
  35.  
  36. part1        PROC
  37.         export    start
  38.         import    part2
  39.  
  40.         jsr    $C300        ;Initialize 80-col screen.
  41.         _writecr
  42.         jsr    home
  43.  
  44. start        lda    #0        ;Clear the variable space.
  45.         tax            ;This application does not
  46. @clearvars    sta    varspace,x    ;need to variables to be
  47.         inx            ;pre-cleared.
  48.         bne    @clearvars
  49.  
  50.         jmp    part2
  51.  
  52.         endp
  53.  
  54. ******************
  55.  
  56. part2        PROC
  57.  
  58.         _rtreset
  59.         _hibitchrs
  60.  
  61.         _write    '8-bit sample application demonstrating ',\
  62.             'macros and runtime.',13,\
  63.             'Copyright (C) 1990 by Apple Computer.',13,\
  64.             '<<< Version 3.0 >>>'
  65.  
  66.         _signed
  67.         _write    13,13,13,13,'  Testing signed output:  '
  68.         _decout    #-1
  69.         _unsigned
  70.         _write    13,'Testing unsigned output:  '
  71.         _decout    #-1
  72.  
  73.         _write    13,13,'  Testing 1-byte decimal output:  '
  74.         _decoutl    #-1
  75.         _write    13,'Testing variable decimal output:  '
  76.         _set    var1,#<123
  77.         _vdecout
  78.  
  79.         _write    13,13,'           hexpad default is to pad with 0''s:  '
  80.         _vhexout
  81.         _hexnopad
  82.         _write    13,'       Testing 2-byte hex output with no pad:  '
  83.         _hexout    #123
  84.         _hexpad    #32
  85.         _write    13,'Testing 2-byte hex output padded with spaces:  '
  86.         _hexout    #123
  87.  
  88.  
  89.         _hexpad    #'0'
  90.         _writecr
  91.         _write    13,'   Testing 1-byte hex output padded with 0''s:  '
  92.         _hexoutl    #15
  93.         _hexnopad
  94.         _write    13,'       Testing 1-byte hex output with no pad:  '
  95.         _hexoutl    #15
  96.         _hexpad    #32
  97.         _write    13,'Testing 1-byte hex output padded with spaces:  '
  98.         _hexoutl    #15
  99.         
  100.         jsr    nextPage
  101.  
  102.         _write    'Testing _addvar:  1234+5678='
  103.         _set    var2,#5678
  104.         _set    var1,#1234
  105.         _addvar    ,var2
  106.         _vdecout
  107.         _write    13,'  Testing _addl:  +123='
  108.         _addl    ,#123
  109.         _vdecout
  110.         _write    13,'   Testing _add:  +456='
  111.         _add    ,#456
  112.         _vdecout
  113.  
  114.         _write    13,13,'Testing _subvar:  5678-1234='
  115.         _set    var2,#1234
  116.         _set    var1,#5678
  117.         _subvar    ,var2
  118.         _vdecout
  119.         _write    13,'  Testing _subl:  -123='
  120.         _subl    ,#123
  121.         _vdecout
  122.         _write    13,'   Testing _sub:  -456='
  123.         _sub    ,#456
  124.         _vdecout
  125.  
  126.         _write    13,13,'Testing _mulvar:  12*345='
  127.         _set    var2,#345
  128.         _set    var1,#<12
  129.         _mulvar    ,var2
  130.         _vdecout
  131.         _write    13,'  Testing _mull:  *6='
  132.         _mull    ,#6
  133.         _vdecout
  134.         _write    13,'   Testing _mul:  *789='
  135.         _mul    ,#789
  136.         _vdecout
  137.         _write    '   (Overflow -- loss of high-order bytes.)'
  138.  
  139.         _write    13,13,'Testing _divvar:  65432/23='
  140.         _set    var2,#<23
  141.         _set    var1,#65432
  142.         _divvar    ,var2
  143.         _set    remainder
  144.         _vdecout    var1
  145.         _write    '  (Remainder='
  146.         _vdecout    remainder
  147.         _rtcout    #')'
  148.         _write    13,'  Testing _divl:  /34='
  149.         _divl    var1,#34
  150.         _set    remainder
  151.         _vdecout    var1
  152.         _write    '         (Remainder='
  153.         _vdecout    remainder
  154.         _rtcout    #')'
  155.         _write    13,'   Testing _div:  /321='
  156.         _div    var1,#321
  157.         _set    remainder
  158.         _vdecout    var1
  159.         _write    '         (Remainder='
  160.         _vdecout    remainder
  161.         _rtcout    #')'
  162.  
  163.         _write    13,13,'Testing dereferencing ($1234 means good):  $'
  164.         _set    var1,**@ptr1        ;var1 has address @ptr3 now.
  165.         _add    ,#<2            ;var1 has address @ptr3+2 now.
  166.         _vderef                ;var1 has address @ptr4 now.
  167.         _vderef                ;var1 has address @ptr5 now.
  168.         _vderef                ;var1 has value from @ptr5 now.
  169.         _vhexout
  170.         jmp    @past
  171.  
  172. @ptr1        dc.w    @ptr2
  173. @ptr2        dc.w    @ptr3
  174. @ptr3        dc.w    0,@ptr4
  175. @ptr4        dc.w    @ptr5
  176. @ptr5        dc.w    $1234
  177.  
  178. @past        jsr    nextPage
  179.  
  180.         _set    var1,#345
  181.         _set0    var1
  182.         _write    'Testing _set0:  '
  183.         _vdecout
  184.         _set    var2,#<2
  185.         _var    var1
  186.         _varcpy    ,var2
  187.         _write    13,'Testing _var and _varcpy (2 means good):  '
  188.         _vdecout
  189.         _set    var1,#345
  190.         _setl    ,#123
  191.         _write    13,'Testing _setl (123 means good):  '
  192.         _vdecout
  193.         _write    13,'Testing _setvars:  '
  194.         _setvars    var1,#123,var2,#456,var3,#789
  195.         _vdecout    var1
  196.         _rtcout    #','
  197.         _vdecout    var2
  198.         _rtcout    #','
  199.         _vdecout    var3
  200.  
  201.         _write    13,13,'  Testing _maxswap (signed):  '
  202.         _set    var1,#-123
  203.         _signed
  204.         _maxswap    var1,var2
  205.         _vdecout
  206.         _rtcout    #','
  207.         _vdecout    var2
  208.         _write    13,'Testing _maxswap (unsigned):  '
  209.         _unsigned
  210.         _maxswap    var1,var2
  211.         _signed
  212.         _vdecout
  213.         _rtcout    #','
  214.         _vdecout    var2
  215.  
  216.         _write    13,'Testing _minswap (unsigned):  '
  217.         _unsigned
  218.         _minswap    var1,var2
  219.         _signed
  220.         _vdecout
  221.         _rtcout    #','
  222.         _vdecout    var2
  223.         _write    13,'  Testing _minswap (signed):  '
  224.         _minswap    var1,var2
  225.         _vdecout
  226.         _rtcout    #','
  227.         _vdecout    var2
  228.         _unsigned
  229.  
  230.         _write    13,13,'Testing _vsgncmp:  -123<456?:  '
  231.         _setvars    var1,#-123,var2,#456
  232.         _vsgncmp    var1,var2
  233.         bcc    @a
  234.         _write    'no'
  235.         jmp    @b
  236. @a        _write    'yes'
  237. @b        _write    13,'   Testing _vcmp:  -123<456?:  '
  238.         _vcmp    var1,var2
  239.         bcc    @c
  240.         _write    'no'
  241.         jmp    @d
  242. @c        _write    'yes'
  243. @d        _write    13,' Testing _sgncmp:  -123<456?:  '
  244.         _sgncmp    var1,#456
  245.         bcc    @e
  246.         _write    'no'
  247.         jmp    @f
  248. @e        _write    'yes'
  249. @f        _write    13,'    Testing _cmp:  -123<456?:  '
  250.         _cmp    var1,#456
  251.         bcc    @g
  252.         _write    'no'
  253.         jmp    @h
  254. @g        _write    'yes'
  255. @h
  256.  
  257.         _readend    #0
  258.         _restore    #strdata
  259.         _readstr    str1
  260.         _prstr
  261.         _readstr    str2
  262.         _strval
  263.         _decout
  264.  
  265.         _readstr    str1
  266.         _prstr
  267.         _midstrval str2,#2
  268.         _decout
  269.  
  270.         _writecr
  271.         _readstr   str1
  272.         _prleftstr str1,#10
  273.         _prmidstr  str1,#10,#5
  274.         _prmidstr  str1,#15,#255
  275.  
  276.         _writecr
  277.         _readstr    str1
  278.         _leftstrcpy str2,str1,#15
  279.         _prstr
  280.         _midstrcpy  ,str1,#15,#5
  281.         _prstr
  282.         _midstrcpy  ,str1,#20
  283.         _prstr
  284.  
  285.         _writecr
  286.         _readstr    str1
  287.         _strcpy    str2,str1
  288.         _prstr
  289.  
  290.         _writecr
  291.         _readstr    str2
  292.         _readstr    str1
  293.  
  294.         _leftstrcat str2,str1,#10
  295.         _midstrcat  ,str1,#10,#5
  296.         _midstrcat  ,str1,#15
  297.         _prstr
  298.  
  299.         _writecr
  300.         _readstr    str1
  301.         _readstr    str2
  302.  
  303.         _strcat    str1,str2
  304.         _prstr
  305.  
  306.         jsr    nextPage
  307.  
  308.         _readstr    str1
  309.         ldy    #0
  310. @loop        cpy    strlens+str1
  311.         beq    @brkloop
  312.         tya
  313.         pha
  314.         _strchr
  315.         _rtcout
  316.         pla
  317.         tay
  318.         iny
  319.         bne    @loop
  320. @brkloop
  321.  
  322.         _litstr    str1,13,'Testing _litstr.'
  323.         _prstr
  324.         _write    13,'Testing _strloc:  str1 is at $'
  325.         _strloc    str1
  326.         _hexout
  327.  
  328.         _write    13,13,'Testing _rndseed:  value passed is:  $'
  329.         _hexnopad
  330.         _hexout    *rndl
  331.         _rndseed    *rndl
  332.         _write    13,13,'Testing _random (200 numbers from 0 to 99):',13,13
  333.         ldx    #10
  334. @loopx        stx    @tempx
  335.         ldy    #20
  336. @loopy        sty    @tempy
  337.         _random    #100        ;This random generator can not generate
  338.         _decout            ;a zero value.  This is okay, since you
  339.         lda    #','        ;can't declare a limit in 2 bytes which
  340.         ldy    @tempy        ;would give you this range.  (To get a
  341.         dey            ;high-end value of 65535, you would have
  342.         bne    @i        ;to have a limit of 65536.
  343.         lda    #13        ;Adjustments for the algorithm not
  344. @i        _rtcout            ;generating a 0 value have been made.
  345.         ldy    @tempy        ;1 is subtracted from the value, thus
  346.         dey            ;moving the problem value from 0 to 65535.
  347.         bne    @loopy        ;Since there is a limit on the 65535 value
  348.         ldx    @tempx        ;anyway, due to not being able to declare
  349.         dex            ;a limit or 65536, this works rather well.
  350.         bne    @loopx
  351.  
  352.         jsr    nextPage
  353.  
  354.         _write    13,'Testing array handling.'
  355.         _write    13,'The array is 2x512x2x4 words.'
  356.  
  357.         _array    #$4000,w,#2,#512,#2,#4
  358.  
  359.         _index    #<1,#379,#<1
  360.         _set    var1,#1234
  361.         _putw    ,#<3
  362.  
  363.         _index    ,#<73
  364.         _set    var1,#5678
  365.         _putw    ,#<4
  366.  
  367.         _write    13,13,'array(1,379,1,3)='
  368.         _index    ,#379,#<1
  369.         _getw    var1,#<3
  370.         _vdecout
  371.  
  372.         _write    13,'array(1,73,0,4)='
  373.         _index    ,#<73
  374.         _getw    var1,#<4
  375.         _vdecout
  376.  
  377.         jsr    nextPage
  378.  
  379.         jmp    start
  380. @tempx        dc.b    0
  381. @tempy        dc.b    0
  382.  
  383.  
  384. strdata        _cstr    13,13,'Testing _readend, _restore, ',\
  385.             '_readstr, and _strval:  '
  386.         _cstr    '12345'
  387.         _cstr    13,'Testing _midstrval:  '
  388.         _cstr    'Testing _prleftstr and _prmidstr.'
  389.         _cstr    'Testing _leftstrcpy and _midstrcpy.'
  390.         _cstr    'Testing _strcpy.'
  391.         _cstr    0,'Testing _leftstrcat and _midstrcat.'
  392.         _cstr    'Testing '
  393.         _cstr    '_strcat.'
  394.         _cstr    13,'Testing _strchr.'
  395.  
  396. nextPage        lda    #22
  397.         sta    cv
  398.         _write    13,'  <<< Press any key to go on (or ESC to quit). >>>'
  399.         bit    $C010
  400. @a        inc    rndl
  401.         bne    @b
  402.         inc    rndh
  403. @b        lda    $C000
  404.         bpl    @a
  405.         bit    $C010
  406.         cmp    #$9B
  407.         beq    @quit
  408.         jmp    home
  409. @quit        jsr    home
  410.         jsr    mli
  411.         dc.b    $65
  412.         dc.w    @quitlist
  413. @quitlist    dc.b    4
  414.         dc.w    0,0,0
  415.  
  416.         endp
  417.  
  418.         END
  419.  
  420.